package com.base.jms;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.apache.activemq.command.ActiveMQTextMessage;
import org.springframework.stereotype.Component;

import com.base.model.User;
import com.base.util.JsonUtil;
import com.base.util.JsonUtil.JsonTypeEnum;

@Component
public class LogMessageConsumer implements MessageListener {

	@Override
	public void onMessage(Message message) {
		try {
			ActiveMQTextMessage tm = (ActiveMQTextMessage)message;
			User user = JsonUtil.use(JsonTypeEnum.Jackson).parseObj(tm.getText(), User.class);
			System.out.println("[activemq log]"+user);
		} catch (JMSException e) {
			e.printStackTrace();
		}
	}

}
